<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dgfile extends Model {

	function Dgfile()
	{
		parent::Model();
	}
	
	//Uploads file and inserts into database
	function upload_file($file, $comment)
	{
	}

	//Returns array of files from database
	function get_files($count)
	{
		if(empty($count))
		{
			$files = $this->db->query('SELECT * FROM files');
		}
		else 
		{
			$files = $this->db->query('SELECT * FROM files LIMIT' . $count);
		}
		return $files;
	}
	
	//Deletes a file from the files folder
	function delete_file($filename)
	{
		$file = 'files/' . $this->uri->segment(3);
		if(! unlink($file))
		{
			return false;
		}
		else 
		{
			return true;
		}
	}
}

?>